package cn.hn.tx.rebot.task.job;

import com.eic.core.spring.BeanFactoryUtil;

import cn.hn.comm.Tools;
import cn.hn.tx.rebot.blog.service.ICrawlBlogService;
import cn.hn.tx.rebot.blog.service.IRebotBlogService;
import cn.hn.tx.rebot.task.model.TaskExeLog;

public class TaskJob_UpdateBlogHot extends ITaskJob {

	// 机器日志服务
	private IRebotBlogService rebotBlogService;

	@Override
	void executeJob() {
		System.out.println("开始:"+getTaskName());
		// 任务执行记录日志
		TaskExeLog taskExeLog = new TaskExeLog();
		taskExeLog.setStartTime(Tools.getCurDate(null));
		taskExeLog.setTaskName(this.getTaskName());
		taskExeLog.setType(type().getType());
		String taskLogMemo;

		try {
			rebotBlogService = (IRebotBlogService) BeanFactoryUtil
					.getBean("RebotBlogService");
			rebotBlogService.updateUserBlogHot();
			taskLogMemo="成功";
		} catch (Exception e) {
			//记录异常
			getExceptionService().insertException(this.getClass().getName(), "executeJob()", e.toString());
			taskLogMemo="任务执行失败.原因:"+e.toString();
		}
		taskExeLog.setMemo(taskLogMemo);
		taskExeLog.setEndTime(Tools.getCurDate(null));
		//记录任务执行日志
		getTaskService().insertTaskExeLog(taskExeLog);
		System.out.println("结束:"+getTaskName());
	}

	@Override
	public
	TaskType type() {
		return TaskType.UpdateBlogHot;
	}

	public IRebotBlogService getRebotBlogService() {
		return rebotBlogService;
	}

	public void setRebotBlogService(IRebotBlogService rebotBlogService) {
		this.rebotBlogService = rebotBlogService;
	}

}
